package com.pcb.controller;

import com.pcb.config.ConstantConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * create by yongli on 2022-04-13 17:30
 */

@RestController
@RequestMapping("/config")
public class StateMonitorController {


    @Autowired
    ConstantConfig constantConfig;
    @Value("${user.name}")
    String name;

    @GetMapping("name")
    public String config(@RequestParam("name") String name) {
        System.out.println(name);
        System.out.println(constantConfig.getName());
        // 需要调用get方法时才会获取值吗
        System.out.println(constantConfig.userName);
        return constantConfig.getName();
    }

    @GetMapping("test")
    public String test() {
        System.out.println(name);
        return name;
    }


}
